package file;

import java.io.File;

public class ListFilesDemo {
    public static void main(String[] args) {
        File dir = new File(".");
        //boolean isFile();
        // boolean isDirectory();

        if (dir.isDirectory()) {
            File[] files = dir.listFiles();
            System.out.println("共有：" + files.length + "个子项");
            for (File file : files) {
                System.out.println(file.getName());
            }
        } else {
            System.out.println("不是目录，或目录不存在");
        }


    }}





